home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume20 / pcomm1.2 / part06 < prev    next >
Encoding:
Internet Message Format  |  1989-10-25  |  54.4 KB

  1. Subject:  v20i072:  Pcomm telecommunication package, Part06/08
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: fthood!egray
  7. Posting-number: Volume 20, Issue 72
  8. Archive-name: pcomm1.2/part06
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create:
  15. #    redial.c
  16. #    s_axfer.c
  17. #    s_extrnl.c
  18. #    s_gen.c
  19. #    s_menu.c
  20. #    s_modem.c
  21. #    s_prompt.c
  22. #    s_term.c
  23. #    s_tty.c
  24. #    screen.c
  25. #    script.c
  26. #    st_line.c
  27. #    status.h
  28. #    strings.c
  29. # This archive created: Fri Feb  3 07:35:32 1989
  30. export PATH; PATH=/bin:/usr/bin:$PATH
  31. echo shar: "extracting 'redial.c'" '(2253 characters)'
  32. if test -f 'redial.c'
  33. then
  34.     echo shar: "will not over-write existing file 'redial.c'"
  35. else
  36. sed 's/^X//' << \SHAR_EOF > 'redial.c'
  37. X/*
  38. X * The redial option (actually a misnomer, it's really a queuing system).
  39. X * We expect a space-separated list of dialing directory entries (although
  40. X * new users always try to put in a phone number).  A non-zero return code
  41. X * means we're ready to dial.
  42. X */
  43. X
  44. X#include <stdio.h>
  45. X#include <curses.h>
  46. X#include "config.h"
  47. X#include "dial_dir.h"
  48. X#include "misc.h"
  49. X
  50. Xint
  51. Xredial()
  52. X{
  53. X    extern int fd;
  54. X    WINDOW *rd_win, *newwin();
  55. X    char *ans, *entry, *get_str(), *strchr(), *strtok();
  56. X    int i, oops, number, ret_code;
  57. X
  58. X    rd_win = newwin(6, 70, 5, 5);
  59. X
  60. X    mvwaddstr(rd_win, 4, 23, "(<CR> for previous numbers)");
  61. X    mvwaddstr(rd_win, 2, 4, "Directory Entry Number(s): ");
  62. X    box(rd_win, VERT, HORZ);
  63. X
  64. X    mvwattrstr(rd_win, 0, 3, A_BOLD, " Redial Queue ");
  65. X    wmove(rd_win, 2, 31);
  66. X    wrefresh(rd_win);
  67. X                    /* get the string of numbers */
  68. X    ret_code = 0;
  69. X    while ((ans = get_str(rd_win, 35, "0123456789+-@# ", "")) != NULL) {
  70. X        oops = 0;
  71. X        if (*ans == '\0') {
  72. X                    /* use previous queue */
  73. X            if (dir->q_num[0] != -1) {
  74. X                ret_code++;
  75. X                break;
  76. X            }
  77. X                    /* there is no previous queue */
  78. X            beep();
  79. X            mvwattrstr(rd_win, 3, 4, A_BOLD, "No previous numbers");
  80. X            wrefresh(rd_win);
  81. X            wait_key(rd_win, 3);
  82. X            clear_line(rd_win, 3, 4, TRUE);
  83. X            wmove(rd_win, 2, 31);
  84. X            wrefresh(rd_win);
  85. X            continue;
  86. X        }
  87. X                    /* parse the queue values */
  88. X        entry = strtok(ans, " \t");
  89. X        for (i=0; i<NUM_QUEUE; i++) {
  90. X            if (*entry == '\0') {
  91. X                dir->q_num[i] = -1;
  92. X                continue;
  93. X            }
  94. X                    /* is there a LD code? */
  95. X            dir->q_ld[i] = '\0';
  96. X            if (strchr("+-@#", *entry)) {
  97. X                dir->q_ld[i] = *entry;
  98. X                entry++;
  99. X            }
  100. X
  101. X            /*
  102. X             * Zero is valid here, because it means use
  103. X             * the current entry information.
  104. X             */
  105. X            number = atoi(entry);
  106. X            if (number < -1 || number > NUM_DIR) {
  107. X                beep();
  108. X                mvwattrstr(rd_win, 3, 4, A_BOLD, "Invalid directory entry number");
  109. X                wrefresh(rd_win);
  110. X                wait_key(rd_win, 3);
  111. X                clear_line(rd_win, 3, 4, TRUE);
  112. X                clear_line(rd_win, 2, 31, TRUE);
  113. X                wrefresh(rd_win);
  114. X                oops++;
  115. X                break;
  116. X            }
  117. X                    /* store the number in the queue */
  118. X            dir->q_num[i] = number;
  119. X            entry = strtok((char *) NULL, " \t");
  120. X        }
  121. X        if (oops)
  122. X            continue;
  123. X        ret_code++;
  124. X        break;
  125. X    }
  126. X    if (fd == -1) {
  127. X        werase(rd_win);
  128. X        wrefresh(rd_win);
  129. X    }
  130. X    delwin(rd_win);
  131. X    return(ret_code);
  132. X}
  133. SHAR_EOF
  134. if test 2253 -ne "`wc -c < 'redial.c'`"
  135. then
  136.     echo shar: "error transmitting 'redial.c'" '(should have been 2253 characters)'
  137. fi
  138. fi
  139. echo shar: "extracting 's_axfer.c'" '(3835 characters)'
  140. if test -f 's_axfer.c'
  141. then
  142.     echo shar: "will not over-write existing file 's_axfer.c'"
  143. else
  144. sed 's/^X//' << \SHAR_EOF > 's_axfer.c'
  145. X/*
  146. X * Display the ASCII transfer setup, query for changes.  A non-zero return
  147. X * code means something was changed.
  148. X */
  149. X
  150. X#include <stdio.h>
  151. X#include <curses.h>
  152. X#include "config.h"
  153. X#include "misc.h"
  154. X#include "param.h"
  155. X
  156. Xint
  157. Xaxfer_setup()
  158. X{
  159. X    extern char *v_yes[];
  160. X    WINDOW *x_win, *newwin();
  161. X    int i, ret_code, num;
  162. X    char *ans, *menu_prompt(), *str_rep();
  163. X    static char *v_cr[4] = {"NONE", "STRIP", "ADD LF", NULL};
  164. X    static char *v_lf[4] = {"NONE", "STRIP", "ADD CR", NULL};
  165. X    static char *v_delay[4] = {"0", "100", "150", NULL};
  166. X
  167. X    x_win = newwin(23, 80, 0, 0);
  168. X
  169. X    horizontal(x_win, 0, 0, 28);
  170. X    mvwattrstr(x_win, 0, 29, A_BOLD, "ASCII Transfer Setup");
  171. X    horizontal(x_win, 0, 50, 29);
  172. X    mvwaddstr(x_win, 3, 33, "ASCII UPLOAD");
  173. X    mvwprintw(x_win, 5, 22, "1) Echo locally ........... %s", param->lecho);
  174. X    mvwprintw(x_win, 6, 22, "2) Expand blank lines ..... %s", param->expand);
  175. X    mvwprintw(x_win, 7, 22, "3) CR delay (ms) .......... %d", param->cr_delay);
  176. X    mvwprintw(x_win, 8, 22, "4) Pace the output ........ %s", param->pace);
  177. X    mvwprintw(x_win, 9, 22, "5) CR translation ......... %s", param->cr_up);
  178. X    mvwprintw(x_win, 10, 22, "6) LF translation ......... %s", param->lf_up);
  179. X    mvwaddstr(x_win, 12, 32, "ASCII DOWNLOAD");
  180. X    mvwprintw(x_win, 14, 22, "7) Transfer timeout (sec) . %d", param->timer);
  181. X    mvwprintw(x_win, 15, 22, "8) CR translation ......... %s", param->cr_dn);
  182. X    mvwprintw(x_win, 16, 22, "9) LF translation ......... %s", param->lf_dn);
  183. X    horizontal(x_win, 19, 0, 80);
  184. X    mvwattrstr(x_win, 20, 0, A_BOLD, "OPTION ==> ");
  185. X    mvwaddstr(x_win, 20, 58, "Press <ESC> to return");
  186. X    wmove(x_win, 20, 12);
  187. X    touchwin(x_win);
  188. X    wrefresh(x_win);
  189. X                    /* get the option number */
  190. X    ret_code = 0;
  191. X    while ((i = get_num(x_win, 1)) != -1) {
  192. X        switch (i) {
  193. X            case 1:
  194. X                if ((ans = menu_prompt(x_win, 5, 50, "Echo locally", v_yes)) != NULL) {
  195. X                    param->lecho = str_rep(param->lecho, ans);
  196. X                    ret_code++;
  197. X                }
  198. X                break;
  199. X            case 2:
  200. X                if ((ans = menu_prompt(x_win, 6, 50, "Expand blank lines", v_yes)) != NULL) {
  201. X                    param->expand = str_rep(param->expand, ans);
  202. X                    ret_code++;
  203. X                }
  204. X                break;
  205. X            case 3:
  206. X                if ((ans = menu_prompt(x_win, 7, 50, "CR delay (ms)", v_delay)) != NULL) {
  207. X                    param->cr_delay = atoi(ans);
  208. X                    ret_code++;
  209. X                }
  210. X                break;
  211. X            case 4:
  212. X                if ((ans = menu_prompt(x_win, 8, 50, "Pace the output", v_yes)) != NULL) {
  213. X                    param->pace = str_rep(param->pace, ans);
  214. X                    ret_code++;
  215. X                }
  216. X                break;
  217. X            case 5:
  218. X                if ((ans = menu_prompt(x_win, 9, 50, "CR translation (upload)", v_cr)) != NULL) {
  219. X                    param->cr_up = str_rep(param->cr_up, ans);
  220. X                    ret_code++;
  221. X                }
  222. X                break;
  223. X            case 6:
  224. X                if ((ans = menu_prompt(x_win, 10, 50, "LF translation (upload)", v_lf)) != NULL) {
  225. X                    param->lf_up = str_rep(param->lf_up, ans);
  226. X                    ret_code++;
  227. X                }
  228. X                break;
  229. X            case 7:
  230. X                if ((num = num_prompt(x_win, 14, 50, "Transfer timeout", "(in seconds)")) != -1) {
  231. X                    if (num > MAX_TIMER || num < MIN_TIMER) {
  232. X                        beep();
  233. X                    /* some reasonable range of values */
  234. X                        if (num < MIN_TIMER)
  235. X                            num = MIN_TIMER;
  236. X                        else
  237. X                            num = MAX_TIMER;
  238. X                        mvwaddstr(x_win, 14, 50, "   ");
  239. X                        wrefresh(x_win);
  240. X                        mvwattrnum(x_win, 14, 50, A_BOLD, num);
  241. X                        wrefresh(x_win);
  242. X                    }
  243. X                    param->timer = num;
  244. X                    ret_code++;
  245. X                }
  246. X                break;
  247. X            case 8:
  248. X                if ((ans = menu_prompt(x_win, 15, 50, "CR translation (download)", v_cr)) != NULL) {
  249. X                    param->cr_dn = str_rep(param->cr_dn, ans);
  250. X                    ret_code++;
  251. X                }
  252. X                break;
  253. X            case 9:
  254. X                if ((ans = menu_prompt(x_win, 16, 50, "LF translation (download)", v_lf)) != NULL) {
  255. X                    param->lf_dn = str_rep(param->lf_dn, ans);
  256. X                    ret_code++;
  257. X                }
  258. X                break;
  259. X            default:
  260. X                beep();
  261. X        }
  262. X        mvwaddch(x_win, 20, 12, (chtype) ' ');
  263. X        clear_line(x_win, 21, 0, FALSE);
  264. X        clear_line(x_win, 22, 0, FALSE);
  265. X        wmove(x_win, 20, 12);
  266. X        wrefresh(x_win);
  267. X    }
  268. X    delwin(x_win);
  269. X    return(ret_code);
  270. X}
  271. SHAR_EOF
  272. if test 3835 -ne "`wc -c < 's_axfer.c'`"
  273. then
  274.     echo shar: "error transmitting 's_axfer.c'" '(should have been 3835 characters)'
  275. fi
  276. fi
  277. echo shar: "extracting 's_extrnl.c'" '(4086 characters)'
  278. if test -f 's_extrnl.c'
  279. then
  280.     echo shar: "will not over-write existing file 's_extrnl.c'"
  281. else
  282. sed 's/^X//' << \SHAR_EOF > 's_extrnl.c'
  283. X/*
  284. X * Display the external protocol setup, query for changes.  A non-zero
  285. X * return code means something was changed.
  286. X */
  287. X
  288. X#include <stdio.h>
  289. X#include <curses.h>
  290. X#include "config.h"
  291. X#include "extrnl.h"
  292. X#include "misc.h"
  293. X
  294. Xint
  295. Xext_setup()
  296. X{
  297. X    extern char *null_ptr;
  298. X    WINDOW *ext_win, *newwin();
  299. X    int i, ret_code;
  300. X    char *str, *get_str();
  301. X    void disp_ext();
  302. X
  303. X    ext_win = newwin(23, 80, 0, 0);
  304. X
  305. X    horizontal(ext_win, 0, 0, 27);
  306. X    mvwattrstr(ext_win, 0, 28, A_BOLD, "External Protocol Setup");
  307. X    horizontal(ext_win, 0, 52, 27);
  308. X    mvwaddstr(ext_win, 3, 36, "UPLOAD");
  309. X    mvwaddstr(ext_win, 5, 8, "Name");
  310. X    mvwaddstr(ext_win, 5, 21, "Command line");
  311. X    mvwaddstr(ext_win, 5, 54, "Requires file list?");
  312. X    mvwaddstr(ext_win, 10, 35, "DOWNLOAD");
  313. X    mvwaddstr(ext_win, 12, 8, "Name");
  314. X    mvwaddstr(ext_win, 12, 21, "Command line");
  315. X    mvwaddstr(ext_win, 12, 54, "Requires file list?");
  316. X                    /* display the current list */
  317. X    disp_ext(ext_win);
  318. X
  319. X    horizontal(ext_win, 19, 0, 80);
  320. X    mvwattrstr(ext_win, 20, 0, A_BOLD, "OPTION ==> ");
  321. X    mvwaddstr(ext_win, 20, 58, "Press <ESC> to return");
  322. X    wmove(ext_win, 20, 12);
  323. X    touchwin(ext_win);
  324. X    wrefresh(ext_win);
  325. X                    /* get the option */
  326. X    ret_code = 0;
  327. X    while ((str = get_str(ext_win, 1, "1234356", "")) != NULL) {
  328. X        switch(*str) {
  329. X            case '1':
  330. X                if (ext_prompt(ext_win, 1, 0, 6))
  331. X                    ret_code++;
  332. X                break;
  333. X            case '2':
  334. X                if (ext_prompt(ext_win, 1, 1, 7))
  335. X                    ret_code++;
  336. X                break;
  337. X            case '3':
  338. X                if (ext_prompt(ext_win, 1, 2, 8))
  339. X                    ret_code++;
  340. X                break;
  341. X            case '4':
  342. X                if (ext_prompt(ext_win, 0, 0, 13))
  343. X                    ret_code++;
  344. X                break;
  345. X            case '5':
  346. X                if (ext_prompt(ext_win, 0, 1, 14))
  347. X                    ret_code++;
  348. X                break;
  349. X            case '6':
  350. X                if (ext_prompt(ext_win, 0, 2, 15))
  351. X                    ret_code++;
  352. X                break;
  353. X        }
  354. X        mvwaddstr(ext_win, 20, 12, "  ");
  355. X        clear_line(ext_win, 21, 0, FALSE);
  356. X        clear_line(ext_win, 22, 0, FALSE);
  357. X        wmove(ext_win, 20, 12);
  358. X        wrefresh(ext_win);
  359. X    }
  360. X    /*
  361. X     * Recalculate the number of entries.  Please notice that if you
  362. X     * create an empty entry (a hole), all entries after that are ignored.  
  363. X     * The software doesn't compact the holes out.. you're on your own.
  364. X     */
  365. X    if (ret_code) {
  366. X        for (i=0; i<3; i++) {
  367. X            if (extrnl->name[1][i] == null_ptr)
  368. X                break;
  369. X        }
  370. X        extrnl->up_entries = i;
  371. X
  372. X        for (i=0; i<3; i++) {
  373. X            if (extrnl->name[0][i] == null_ptr)
  374. X                break;
  375. X        }
  376. X        extrnl->dn_entries = i;
  377. X    }
  378. X    delwin(ext_win);
  379. X    return(ret_code);
  380. X}
  381. X
  382. X/*
  383. X * Display the current list of external file transfer programs.
  384. X */
  385. X
  386. Xstatic void
  387. Xdisp_ext(win)
  388. XWINDOW *win;
  389. X{
  390. X    int i, up, entry, line;
  391. X
  392. X    up = 1;
  393. X    line = 6;
  394. X    for (i=0; i<6; i++) {
  395. X        if (i < 3)
  396. X            entry = i;
  397. X        else {
  398. X            up = 0;
  399. X            entry = i-3;
  400. X            line = 10;
  401. X        }
  402. X        mvwprintw(win, i+line, 5, "%d) %-12.12s %-40.40s  %c\n",
  403. X         i+1, extrnl->name[up][entry], extrnl->command[up][entry],
  404. X         extrnl->prompt[up][entry]);
  405. X    }
  406. X    return;
  407. X}
  408. X
  409. X/*
  410. X * Prompt for the info in the database.  A non-zero return code means
  411. X * that something was changed.  To delete the line, you enter a single
  412. X * space character at the first prompt.
  413. X */
  414. X
  415. Xstatic int
  416. Xext_prompt(win, up, entry, line)
  417. XWINDOW *win;
  418. Xint up, entry, line;
  419. X{
  420. X    extern char *v_yn[], *null_ptr;
  421. X    char *ans, t_name[80], t_command[80], *str_prompt(), *str_rep();
  422. X    char *strcpy(), *menu_prompt();
  423. X
  424. X                    /* get temp name */
  425. X    if ((ans = str_prompt(win, line, 8, "Protocol name", "")) == NULL)
  426. X        return(0);
  427. X
  428. X    strcpy(t_name, ans);
  429. X    clear_line(win, 21, 0, FALSE);
  430. X                    /* are we zapping the line */
  431. X    if (ans == null_ptr) {
  432. X        extrnl->name[up][entry] = null_ptr;
  433. X        extrnl->command[up][entry] = null_ptr;
  434. X        extrnl->prompt[up][entry] = 'N';
  435. X        return(1);
  436. X    }
  437. X                    /* get temp command */
  438. X    if ((ans = str_prompt(win, line, 21, "Command line", "")) == NULL)
  439. X        return(0);
  440. X
  441. X    strcpy(t_command, ans);
  442. X    clear_line(win, 21, 0, FALSE);
  443. X
  444. X                    /* get temp prompt */
  445. X    if ((ans = menu_prompt(win, line, 63, "Does it require a file list", v_yn)) == NULL)
  446. X        return(0);
  447. X
  448. X    wrefresh(win);
  449. X                    /* store 'em for real */
  450. X    extrnl->name[up][entry] = str_rep(extrnl->name[up][entry], t_name);
  451. X    extrnl->command[up][entry] = str_rep(extrnl->command[up][entry], t_command);
  452. X    extrnl->prompt[up][entry] = *ans;
  453. X
  454. X    return(1);
  455. X}
  456. SHAR_EOF
  457. if test 4086 -ne "`wc -c < 's_extrnl.c'`"
  458. then
  459.     echo shar: "error transmitting 's_extrnl.c'" '(should have been 4086 characters)'
  460. fi
  461. fi
  462. echo shar: "extracting 's_gen.c'" '(4402 characters)'
  463. if test -f 's_gen.c'
  464. then
  465.     echo shar: "will not over-write existing file 's_gen.c'"
  466. else
  467. sed 's/^X//' << \SHAR_EOF > 's_gen.c'
  468. X/*
  469. X * Display the general setup, query for changes.  A non-zero return code
  470. X * means something was changed.
  471. X */
  472. X
  473. X#include <stdio.h>
  474. X#include <curses.h>
  475. X#include "config.h"
  476. X#include "misc.h"
  477. X#include "param.h"
  478. X
  479. Xint
  480. Xgen_setup()
  481. X{
  482. X    extern char *v_yes[];
  483. X    WINDOW *g_win, *newwin();
  484. X    int i, num, ret_code;
  485. X    char c, *ans, *str_prompt(), *menu_prompt(), chr_prompt();
  486. X    char *str_rep();
  487. X    void line_set();
  488. X    static char *v_abort[3] = {"KEEP", "DELETE", NULL};
  489. X
  490. X    g_win = newwin(23, 80, 0, 0);
  491. X
  492. X    horizontal(g_win, 0, 0, 32);
  493. X    mvwattrstr(g_win, 0, 33, A_BOLD, "General Setup");
  494. X    horizontal(g_win, 0, 47, 32);
  495. X    mvwprintw(g_win, 3, 22, "1) Default log file ....... %s", param->logfile);
  496. X    mvwprintw(g_win, 4, 22, "2) Screen dump file ....... %s", param->dumpfile);
  497. X    mvwprintw(g_win, 6, 22, "3) Strip high bit  ........ %s", param->strip);
  498. X    mvwprintw(g_win, 8, 22, "4) Pause character ........ %c", param->pause_char);
  499. X    mvwprintw(g_win, 9, 22, "5) CR character ........... %c", param->cr_char);
  500. X    mvwprintw(g_win, 10, 22, "6) CTRL character ......... %c", param->ctrl_char);
  501. X    mvwprintw(g_win, 11, 22, "7) ESC character .......... %c", param->esc_char);
  502. X    mvwprintw(g_win, 12, 22, "8) Break character ........ %c", param->brk_char);
  503. X    mvwprintw(g_win, 14, 22, "9) Aborted downloads ...... %s", param->abort);
  504. X    mvwprintw(g_win, 16, 21, "10) Connect delay (sec) .... %d", param->c_delay);
  505. X    mvwprintw(g_win, 17, 21, "11) Redial delay (sec) ..... %d", param->r_delay);
  506. X    horizontal(g_win, 19, 0, 80);
  507. X    mvwattrstr(g_win, 20, 0, A_BOLD, "OPTION ==> ");
  508. X    mvwaddstr(g_win, 20, 58, "Press <ESC> to return");
  509. X    wmove(g_win, 20, 12);
  510. X    touchwin(g_win);
  511. X    wrefresh(g_win);
  512. X                    /* get the option number */
  513. X    ret_code = 0;
  514. X    while ((i = get_num(g_win, 2)) != -1) {
  515. X        switch (i) {
  516. X            case 1:
  517. X                if ((ans = str_prompt(g_win, 3, 50, "Default log file", "")) != NULL) {
  518. X                    param->logfile = str_rep(param->logfile, ans);
  519. X                    ret_code++;
  520. X                }
  521. X                break;
  522. X            case 2:
  523. X                if ((ans = str_prompt(g_win, 4, 50, "Default screen dump file", "")) != NULL) {
  524. X                    param->dumpfile = str_rep(param->dumpfile, ans);
  525. X                    ret_code++;
  526. X                }
  527. X                break;
  528. X            case 3:
  529. X                if ((ans = menu_prompt(g_win, 6, 50, "Strip high bit?", v_yes)) != NULL) {
  530. X                    param->strip = str_rep(param->strip, ans);
  531. X                    line_set();
  532. X                    ret_code++;
  533. X                }
  534. X                break;
  535. X            case 4:
  536. X                if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != '\0') {
  537. X                    param->pause_char = c;
  538. X                    ret_code++;
  539. X                }
  540. X                break;
  541. X            case 5:
  542. X                if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != '\0') {
  543. X                    param->cr_char = c;
  544. X                    ret_code++;
  545. X                }
  546. X                break;
  547. X            case 6:
  548. X                if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != '\0') {
  549. X                    param->ctrl_char = c;
  550. X                    ret_code++;
  551. X                }
  552. X                break;
  553. X            case 7:
  554. X                if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != '\0') {
  555. X                    param->esc_char = c;
  556. X                    ret_code++;
  557. X                }
  558. X                break;
  559. X            case 8:
  560. X                if ((c = chr_prompt(g_win, 12, 50, "Break character", "")) != '\0') {
  561. X                    param->brk_char = c;
  562. X                    ret_code++;
  563. X                }
  564. X            case 9:
  565. X                if ((ans = menu_prompt(g_win, 14, 50, "Aborted downloads", v_abort)) != NULL) {
  566. X                    param->abort = str_rep(param->abort, ans);
  567. X                    ret_code++;
  568. X                }
  569. X                break;
  570. X            case 10:
  571. X                if ((num = num_prompt(g_win, 16, 50, "Connect delay time", "(in seconds)")) != -1) {
  572. X                    if (num > MAX_CDELAY || num < MIN_CDELAY) {
  573. X                        beep();
  574. X                    /* some reasonable range of values */
  575. X                        if (num < MIN_CDELAY)
  576. X                            num = MIN_CDELAY;
  577. X                        else
  578. X                            num = MAX_CDELAY;
  579. X                        mvwaddstr(g_win, 16, 50, "   ");
  580. X                        wrefresh(g_win);
  581. X                        mvwattrnum(g_win, 16, 50, A_BOLD, num);
  582. X                        wrefresh(g_win);
  583. X                    }
  584. X                    param->c_delay = num;
  585. X                    ret_code++;
  586. X                }
  587. X                break;
  588. X            case 11:
  589. X                if ((num = num_prompt(g_win, 17, 50, "Redial delay time", "(in seconds)")) != -1) {
  590. X                    if (num > MAX_PAUSE || num < MIN_PAUSE) {
  591. X                        beep();
  592. X                    /* some reasonable range */
  593. X                        if (num < MIN_PAUSE)
  594. X                            num = MIN_PAUSE;
  595. X                        else
  596. X                            num = MAX_PAUSE;
  597. X                        mvwaddstr(g_win, 17, 50, "    ");
  598. X                        wrefresh(g_win);
  599. X                        mvwattrnum(g_win, 17, 50, A_BOLD, num);
  600. X                        wrefresh(g_win);
  601. X                    }
  602. X                    param->r_delay = num;
  603. X                    ret_code++;
  604. X                }
  605. X                break;
  606. X            default:
  607. X                beep();
  608. X        }
  609. X        mvwaddstr(g_win, 20, 12, "  ");
  610. X        clear_line(g_win, 21, 0, FALSE);
  611. X        clear_line(g_win, 22, 0, FALSE);
  612. X        wmove(g_win, 20, 12);
  613. X        wrefresh(g_win);
  614. X    }
  615. X    delwin(g_win);
  616. X    return(ret_code);
  617. X}
  618. SHAR_EOF
  619. if test 4402 -ne "`wc -c < 's_gen.c'`"
  620. then
  621.     echo shar: "error transmitting 's_gen.c'" '(should have been 4402 characters)'
  622. fi
  623. fi
  624. echo shar: "extracting 's_menu.c'" '(3200 characters)'
  625. if test -f 's_menu.c'
  626. then
  627.     echo shar: "will not over-write existing file 's_menu.c'"
  628. else
  629. sed 's/^X//' << \SHAR_EOF > 's_menu.c'
  630. X/*
  631. X * Display the setup menu, prompts for a bunch of other menus.  A non-zero
  632. X * return code means we have to restart the input routine.
  633. X */
  634. X
  635. X#include <stdio.h>
  636. X#include <curses.h>
  637. X#include "config.h"
  638. X#include "misc.h"
  639. X
  640. Xint
  641. Xsetup_menu()
  642. X{
  643. X    extern int fd, xmc;
  644. X    WINDOW *s_win, *newwin();
  645. X    char *ans, *get_str();
  646. X    int param_flag, modem_flag, ext_flag, ret_code;
  647. X    void top_line();
  648. X
  649. X    s_win = newwin(23, 80, 0, 0);
  650. X
  651. X    top_line(s_win);
  652. X    mvwaddstr(s_win, 3, 29, "1) TTY Setup");
  653. X    mvwaddstr(s_win, 5, 29, "2) Modem Setup");
  654. X    mvwaddstr(s_win, 7, 29, "3) Terminal Setup");
  655. X    mvwaddstr(s_win, 9, 29, "4) General Setup");
  656. X    mvwaddstr(s_win, 11, 29, "5) ASCII Transfer Setup");
  657. X    mvwaddstr(s_win, 13, 29, "6) External Protocol Setup");
  658. X    mvwaddstr(s_win, 15, 29, "S) Save setup to disk");
  659. X    horizontal(s_win, 19, 0, 80);
  660. X    mvwattrstr(s_win, 20, 0, A_BOLD, "OPTION ==> ");
  661. X    mvwaddstr(s_win, 20, 58, "  Press <ESC> to exit");
  662. X    wmove(s_win, 20, 12);
  663. X    touchwin(s_win);
  664. X    wrefresh(s_win);
  665. X
  666. X    param_flag = 0;
  667. X    modem_flag = 0;
  668. X    ext_flag = 0;
  669. X    ret_code = 0;
  670. X                    /* get the options */
  671. X    while ((ans = get_str(s_win, 1, "123456Ss", "")) != NULL) {
  672. X        if (xmc > 0) {
  673. X            clear_line(s_win, 0, 0, FALSE);
  674. X            wrefresh(s_win);
  675. X        }
  676. X        switch (*ans) {
  677. X            case '1':
  678. X                if (tty_setup())
  679. X                    modem_flag++;
  680. X                break;
  681. X            case '2':
  682. X                if (modem_setup())
  683. X                    modem_flag++;
  684. X                break;
  685. X            case '3':
  686. X                /*
  687. X                 * term_setup() returns a 1 if something was
  688. X                 * changed, and a 2 if the change requires
  689. X                 * the input routine to be restarted.
  690. X                 */
  691. X                if (ret_code = term_setup()) {
  692. X                    ret_code--;
  693. X                    param_flag++;
  694. X                }
  695. X                break;
  696. X            case '4':
  697. X                if (gen_setup())
  698. X                    param_flag++;
  699. X                break;
  700. X            case '5':
  701. X                if (axfer_setup())
  702. X                    param_flag++;
  703. X                break;
  704. X            case '6':
  705. X                if (ext_setup())
  706. X                    ext_flag++;
  707. X                break;
  708. X            case 's':
  709. X            case 'S':
  710. X                if (xmc > 0)
  711. X                    top_line(s_win);
  712. X                /*
  713. X                 * Writes to disk are not critical, since
  714. X                 * the changes are made in memory.
  715. X                 */
  716. X                if (param_flag) {
  717. X                    mvwattrstr(s_win, 22, 27, A_BLINK, "Updating Parameter File");
  718. X                    wrefresh(s_win);
  719. X                    wait_key(s_win, 3);
  720. X                    if (up_param()) {
  721. X                        touchwin(s_win);
  722. X                        wrefresh(s_win);
  723. X                    }
  724. X                }
  725. X                if (modem_flag) {
  726. X                    mvwattrstr(s_win, 22, 27, A_BLINK, "Updating Modem Database");
  727. X                    wrefresh(s_win);
  728. X                    wait_key(s_win, 3);
  729. X                    if (up_modem()) {
  730. X                        touchwin(s_win);
  731. X                        wrefresh(s_win);
  732. X                    }
  733. X                }
  734. X                if (ext_flag) {
  735. X                    mvwattrstr(s_win, 22, 25, A_BLINK, "Updating External Protocols");
  736. X                    wrefresh(s_win);
  737. X                    wait_key(s_win, 3);
  738. X                    if (up_extrnl()) {
  739. X                        touchwin(s_win);
  740. X                        wrefresh(s_win);
  741. X                    }
  742. X                }
  743. X                clear_line(s_win, 22, 25, FALSE);
  744. X                wrefresh(s_win);
  745. X                break;
  746. X            default:
  747. X                beep();
  748. X        }
  749. X        touchwin(s_win);
  750. X        if (xmc > 0)
  751. X            top_line(s_win);
  752. X
  753. X        mvwaddch(s_win, 20, 12, (chtype) ' ');
  754. X        wmove(s_win, 20, 12);
  755. X        wrefresh(s_win);
  756. X    }
  757. X    if (fd == -1) {
  758. X        werase(s_win);
  759. X        wrefresh(s_win);
  760. X    }
  761. X    delwin(s_win);
  762. X    return(ret_code);
  763. X}
  764. X
  765. X/*
  766. X * Put the top line on the window.
  767. X */
  768. X
  769. Xvoid
  770. Xtop_line(win)
  771. XWINDOW *win;
  772. X{
  773. X    clear_line(win, 0, 0, FALSE);
  774. X    wrefresh(win);
  775. X    horizontal(win, 0, 0, 33);
  776. X    mvwattrstr(win, 0, 34, A_BOLD, "Setup Menu");
  777. X    horizontal(win, 0, 45, 34);
  778. X    wrefresh(win);
  779. X    return;
  780. X}
  781. SHAR_EOF
  782. if test 3200 -ne "`wc -c < 's_menu.c'`"
  783. then
  784.     echo shar: "error transmitting 's_menu.c'" '(should have been 3200 characters)'
  785. fi
  786. fi
  787. echo shar: "extracting 's_modem.c'" '(6656 characters)'
  788. if test -f 's_modem.c'
  789. then
  790.     echo shar: "will not over-write existing file 's_modem.c'"
  791. else
  792. sed 's/^X//' << \SHAR_EOF > 's_modem.c'
  793. X/*
  794. X * Display the modem setup, query for changes.  A non-zero return code
  795. X * means something was changed.
  796. X */
  797. X
  798. X#include <stdio.h>
  799. X#include <curses.h>
  800. X#include "config.h"
  801. X#include "misc.h"
  802. X#include "modem.h"
  803. X
  804. Xint
  805. Xmodem_setup()
  806. X{
  807. X    WINDOW *mo_win, *newwin();
  808. X    int i, j, ret_code, mod_prompt();
  809. X    char *ans, *str_rep(), *str_prompt(), *menu_prompt();
  810. X    void disp_modem();
  811. X    extern char *v_yn[];
  812. X                    /* the current modem */
  813. X    j = 0;
  814. X    if (modem->m_cur != -1)
  815. X        j = modem->m_cur;
  816. X
  817. X    mo_win = newwin(23, 80, 0, 0);
  818. X
  819. X    horizontal(mo_win, 0, 0, 33);
  820. X    mvwattrstr(mo_win, 0, 34, A_BOLD, "Modem Setup");
  821. X    horizontal(mo_win, 0, 46, 34);
  822. X                    /* display the current settings */
  823. X    disp_modem(mo_win, j);
  824. X    horizontal(mo_win, 19, 0, 80);
  825. X    mvwattrstr(mo_win, 20, 0, A_BOLD, "OPTION ==> ");
  826. X    mvwaddstr(mo_win, 20, 58, "Press <ESC> to return");
  827. X    wmove(mo_win, 20, 12);
  828. X    touchwin(mo_win);
  829. X    wrefresh(mo_win);
  830. X                    /* get the option number */
  831. X    ret_code = 0;
  832. X    while ((i = get_num(mo_win, 2)) != -1) {
  833. X        switch (i) {
  834. X            case 1:
  835. X                j = mod_prompt(mo_win);
  836. X                break;
  837. X            case 2:
  838. X                if ((ans = str_prompt(mo_win, 3, 39, "Modem init string", "sent to the modem once")) != NULL) {
  839. X                    modem->init[j] = str_rep(modem->init[j], ans);
  840. X                    ret_code++;
  841. X                }
  842. X                break;
  843. X            case 3:
  844. X                if ((ans = str_prompt(mo_win, 4, 39, "Dialing command", "")) != NULL) {
  845. X                    modem->dial[j] = str_rep(modem->dial[j], ans);
  846. X                    ret_code++;
  847. X                }
  848. X                break;
  849. X            case 4:
  850. X                if ((ans = str_prompt(mo_win, 5, 39, "Dialing cmd suffix", "typically the <CR> character")) != NULL) {
  851. X                    modem->suffix[j] = str_rep(modem->suffix[j], ans);
  852. X                    ret_code++;
  853. X                }
  854. X                break;
  855. X            case 5:
  856. X                if ((ans = str_prompt(mo_win, 6, 39, "Hang up string", "")) != NULL) {
  857. X                    modem->hang_up[j] = str_rep(modem->hang_up[j], ans);
  858. X                    ret_code++;
  859. X                }
  860. X                break;
  861. X            case 6:
  862. X                if ((ans = menu_prompt(mo_win, 7, 39, "Auto Baud detect", v_yn)) != NULL) {
  863. X                    modem->auto_baud[j] = *ans;
  864. X                    ret_code++;
  865. X                }
  866. X                break;
  867. X            case 7:
  868. X                if ((ans = str_prompt(mo_win, 8, 39, "300 baud connect string", "")) != NULL) {
  869. X                    modem->con_3[j] = str_rep(modem->con_3[j], ans);
  870. X                    ret_code++;
  871. X                }
  872. X                break;
  873. X            case 8:
  874. X                if ((ans = str_prompt(mo_win, 9, 39, "1200 baud connect string", "")) != NULL) {
  875. X                    modem->con_12[j] = str_rep(modem->con_12[j], ans);
  876. X                    ret_code++;
  877. X                }
  878. X                break;
  879. X            case 9:
  880. X                if ((ans = str_prompt(mo_win, 10, 39, "2400 baud connect string", "")) != NULL) {
  881. X                    modem->con_24[j] = str_rep(modem->con_24[j], ans);
  882. X                    ret_code++;
  883. X                }
  884. X                break;
  885. X            case 10:
  886. X                if ((ans = str_prompt(mo_win, 11, 39, "4800 baud connect string", "")) != NULL) {
  887. X                    modem->con_48[j] = str_rep(modem->con_48[j], ans);
  888. X                    ret_code++;
  889. X                }
  890. X                break;
  891. X            case 11:
  892. X                if ((ans = str_prompt(mo_win, 12, 39, "9600 baud connect string", "")) != NULL) {
  893. X                    modem->con_96[j] = str_rep(modem->con_96[j], ans);
  894. X                    ret_code++;
  895. X                }
  896. X                break;
  897. X            case 12:
  898. X                if ((ans = str_prompt(mo_win, 13, 39, "19200 baud connect string", "")) != NULL) {
  899. X                    modem->con_192[j] = str_rep(modem->con_192[j], ans);
  900. X                    ret_code++;
  901. X                }
  902. X                break;
  903. X            case 13:
  904. X                if ((ans = str_prompt(mo_win, 14, 39, "No connect string 1", "")) != NULL) {
  905. X                    modem->no_con1[j] = str_rep(modem->no_con1[j], ans);
  906. X                    ret_code++;
  907. X                }
  908. X                break;
  909. X            case 14:
  910. X                if ((ans = str_prompt(mo_win, 15, 39, "No connect string 2", "")) != NULL) {
  911. X                    modem->no_con2[j] = str_rep(modem->no_con2[j], ans);
  912. X                    ret_code++;
  913. X                }
  914. X                break;
  915. X            case 15:
  916. X                if ((ans = str_prompt(mo_win, 16, 39, "No connect string 3", "")) != NULL) {
  917. X                    modem->no_con3[j] = str_rep(modem->no_con3[j], ans);
  918. X                    ret_code++;
  919. X                }
  920. X                break;
  921. X            case 16:
  922. X                if ((ans = str_prompt(mo_win, 17, 39, "No connect string 4", "")) != NULL) {
  923. X                    modem->no_con4[j] = str_rep(modem->no_con4[j], ans);
  924. X                    ret_code++;
  925. X                }
  926. X                break;
  927. X            default:
  928. X                beep();
  929. X        }
  930. X                    /* clear the previous prompts */
  931. X        mvwaddstr(mo_win, 20, 12, "   ");
  932. X        clear_line(mo_win, 21, 0, FALSE);
  933. X        clear_line(mo_win, 22, 0, FALSE);
  934. X        wmove(mo_win, 20, 12);
  935. X        wrefresh(mo_win);
  936. X    }
  937. X    delwin(mo_win);
  938. X    return(ret_code);
  939. X}
  940. X
  941. X/*
  942. X * Prompts for the modem name.  The user selects the currently showing
  943. X * choice by hitting a carriage return.  Returns the modem entry number.
  944. X * DOES NOT change the value of modem->m_cur.
  945. X */
  946. X
  947. Xstatic int
  948. Xmod_prompt(win)
  949. XWINDOW *win;
  950. X{
  951. X    char ans;
  952. X    int i;
  953. X                    /* print prompt lines */
  954. X    mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
  955. X    mvwaddstr(win, 21, 0, "Modem name: ");
  956. X                    /* show current choice */
  957. X    i = 0;
  958. X    if (modem->m_cur != -1)
  959. X        i = modem->m_cur;
  960. X    mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
  961. X    wmove(win, 21, 12);
  962. X    wrefresh(win);
  963. X                    /* show the choices one at a time */
  964. X    while ((ans = wgetch(win)) != '\r') {
  965. X        i++;
  966. X        if (*modem->mname[i] == '\0')
  967. X            i = 0;
  968. X        if (ans == ESC)
  969. X            return(0);
  970. X        mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
  971. X        wmove(win, 21, 12);
  972. X        wrefresh(win);
  973. X    }
  974. X                    /* display the new values */
  975. X    disp_modem(win, i);
  976. X                    /* display the name in bold */
  977. X    clear_line(win, 2, 39, FALSE);
  978. X    wrefresh(win);
  979. X    mvwattrstr(win, 2, 39, A_BOLD, modem->mname[i]);
  980. X    mvwprintw(win, 2, 25, "(%d of %d) ", i+1, modem->m_entries);
  981. X
  982. X    return(i);
  983. X}
  984. X
  985. X/*
  986. X * Show the current settings for the given modem entry number.
  987. X */
  988. X
  989. Xstatic void
  990. Xdisp_modem(w, i)
  991. XWINDOW *w;
  992. Xint i;
  993. X{
  994. X    mvwprintw(w, 2, 11, "1) Modem name ............. %-39.39s", modem->mname[i]);
  995. X    mvwprintw(w, 2, 25, "(%d of %d) ", i+1, modem->m_entries);
  996. X    mvwprintw(w, 3, 11, "2) Modem init string ...... %-39.39s", modem->init[i]);
  997. X    mvwprintw(w, 4, 11, "3) Dialing command ........ %-39.39s", modem->dial[i]);
  998. X    mvwprintw(w, 5, 11, "4) Dialing cmd suffix ..... %-39.39s", modem->suffix[i]);
  999. X    mvwprintw(w, 6, 11, "5) Hang up string ......... %-39.39s", modem->hang_up[i]);
  1000. X    mvwprintw(w, 7, 11, "6) Auto baud detect ....... %c", modem->auto_baud[i]);
  1001. X    mvwprintw(w, 8, 11, "7) 300 baud connect ....... %-39.39s", modem->con_3[i]);
  1002. X    mvwprintw(w, 9, 11, "8) 1200 baud connect ...... %-39.39s", modem->con_12[i]);
  1003. X    mvwprintw(w, 10, 11, "9) 2400 baud connect ...... %-39.39s", modem->con_24[i]);
  1004. X    mvwprintw(w, 11, 10, "10) 4800 baud connect ...... %-39.39s", modem->con_48[i]);
  1005. X    mvwprintw(w, 12, 10, "11) 9600 baud connect ...... %-39.39s", modem->con_96[i]);
  1006. X    mvwprintw(w, 13, 10, "12) 19200 baud connect ..... %-39.39s", modem->con_192[i]);
  1007. X    mvwprintw(w, 14, 10, "13) No connect string 1 .... %-39.39s", modem->no_con1[i]);
  1008. X    mvwprintw(w, 15, 10, "14) No connect string 2 .... %-39.39s", modem->no_con2[i]);
  1009. X    mvwprintw(w, 16, 10, "15) No connect string 3 .... %-39.39s", modem->no_con3[i]);
  1010. X    mvwprintw(w, 17, 10, "16) No connect string 4 .... %-39.39s", modem->no_con4[i]);
  1011. X    return;
  1012. X}
  1013. SHAR_EOF
  1014. if test 6656 -ne "`wc -c < 's_modem.c'`"
  1015. then
  1016.     echo shar: "error transmitting 's_modem.c'" '(should have been 6656 characters)'
  1017. fi
  1018. fi
  1019. echo shar: "extracting 's_prompt.c'" '(3089 characters)'
  1020. if test -f 's_prompt.c'
  1021. then
  1022.     echo shar: "will not over-write existing file 's_prompt.c'"
  1023. else
  1024. sed 's/^X//' << \SHAR_EOF > 's_prompt.c'
  1025. X/*
  1026. X * Prompting routines used in the setup menus.
  1027. X */
  1028. X
  1029. X#include <stdio.h>
  1030. X#include <curses.h>
  1031. X#include "config.h"
  1032. X#include "misc.h"
  1033. X
  1034. X/*
  1035. X * Prompt for a string at line 21 (with optional line 22 for additional
  1036. X * information).  Display the new string in bold at its original location
  1037. X * in the menu.  Used in virtually all of the *_setup() routines.  Since
  1038. X * it uses get_str(), the return value points to a static area.
  1039. X */
  1040. X
  1041. Xchar *
  1042. Xstr_prompt(win, y, x, p1, p2)
  1043. XWINDOW *win;
  1044. Xint y, x;
  1045. Xchar *p1, *p2;
  1046. X{
  1047. X    extern char *null_ptr;
  1048. X    char *ans, *get_str();
  1049. X                    /* print first prompt last */
  1050. X    mvwaddstr(win, 22, 0, p2);
  1051. X    mvwaddstr(win, 21, 0, p1);
  1052. X    waddstr(win, ": ");
  1053. X    wrefresh(win);
  1054. X
  1055. X    if ((ans = get_str(win, 80, "", "\n")) == NULL)
  1056. X        return(NULL);
  1057. X                    /* check the value */
  1058. X    if (!strcmp(ans, " "))
  1059. X        ans = null_ptr;
  1060. X                    /* display the value in bold */
  1061. X    clear_line(win, y, x, FALSE);
  1062. X    wattrstr(win, A_BOLD, ans);
  1063. X
  1064. X    return(ans);
  1065. X}
  1066. X
  1067. X/*
  1068. X * Same as above, except we return a single character.
  1069. X */
  1070. X
  1071. Xchar
  1072. Xchr_prompt(win, y, x, p1, p2)
  1073. XWINDOW *win;
  1074. Xint y, x;
  1075. Xchar *p1, *p2;
  1076. X{
  1077. X    char *ans, *get_str();
  1078. X                    /* print first prompt last */
  1079. X    mvwaddstr(win, 22, 0, p2);
  1080. X    mvwaddstr(win, 21, 0, p1);
  1081. X    waddstr(win, ": ");
  1082. X    wrefresh(win);
  1083. X
  1084. X    if ((ans = get_str(win, 1, "", "\n")) == NULL)
  1085. X        return('\0');
  1086. X                    /* display the value in bold */
  1087. X    mvwaddstr(win, y, x, "  ");
  1088. X    wrefresh(win);
  1089. X    mvwattrstr(win, y, x, A_BOLD, ans);
  1090. X
  1091. X    return(*ans);
  1092. X}
  1093. X
  1094. X/*
  1095. X * Same as above, except that it prompts for a three digit number.
  1096. X */
  1097. X
  1098. Xint
  1099. Xnum_prompt(win, y, x, p1, p2)
  1100. XWINDOW *win;
  1101. Xint y, x;
  1102. Xchar *p1, *p2;
  1103. X{
  1104. X    int i;
  1105. X                    /* print first prompt last */
  1106. X    mvwaddstr(win, 22, 0, p2);
  1107. X    mvwaddstr(win, 21, 0, p1);
  1108. X    waddstr(win, ": ");
  1109. X    wrefresh(win);
  1110. X
  1111. X    if ((i = get_num(win, 3)) == -1)
  1112. X        return(-1);
  1113. X                    /* display the value in bold */
  1114. X    mvwaddstr(win, y, x, "    ");
  1115. X    wrefresh(win);
  1116. X    mvwattrnum(win, y, x, A_BOLD, i);
  1117. X                    /* return the number */
  1118. X    return(i);
  1119. X}
  1120. X
  1121. X/*
  1122. X * Prompts for a selection from a menu.  We display the prompt lines,
  1123. X * and show the choices one at a time.  The user selects the currently
  1124. X * showing choice by hitting a carriage return.  Unlike the similar
  1125. X * routines in d_prompt(), the first choice shown is not necessarily
  1126. X * the current.
  1127. X */
  1128. X
  1129. Xchar *v_yes[3] = {"YES", "NO", NULL};
  1130. Xchar *v_yn[3] = {"Y", "N", NULL};
  1131. X
  1132. Xchar *
  1133. Xmenu_prompt(win, y, x, p, menu)
  1134. XWINDOW *win;
  1135. Xint y, x;
  1136. Xchar *p, *menu[];
  1137. X{
  1138. X    char ans;
  1139. X    int i, cy, cx;
  1140. X                    /* print first prompt last */
  1141. X    mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
  1142. X    mvwaddstr(win, 21, 0, p);
  1143. X    waddstr(win, ": ");
  1144. X                    /* show first choice */
  1145. X    i = 0;
  1146. X    getyx(win, cy, cx);
  1147. X    mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  1148. X    wmove(win, cy, cx);
  1149. X    wrefresh(win);
  1150. X                    /* show the choices one at a time */
  1151. X    while ((ans = wgetch(win)) != '\r') {
  1152. X        i++;
  1153. X        if (menu[i] == NULL)
  1154. X            i = 0;
  1155. X        if (ans == ESC)
  1156. X            return(NULL);
  1157. X        mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  1158. X        wmove(win, cy, cx);
  1159. X        wrefresh(win);
  1160. X    }
  1161. X                    /* display the value in bold */
  1162. X    clear_line(win, y, x, FALSE);
  1163. X    wattrstr(win, A_BOLD, menu[i]);
  1164. X                    /* return the value */
  1165. X    return(menu[i]);
  1166. X}
  1167. SHAR_EOF
  1168. if test 3089 -ne "`wc -c < 's_prompt.c'`"
  1169. then
  1170.     echo shar: "error transmitting 's_prompt.c'" '(should have been 3089 characters)'
  1171. fi
  1172. fi
  1173. echo shar: "extracting 's_term.c'" '(3046 characters)'
  1174. if test -f 's_term.c'
  1175. then
  1176.     echo shar: "will not over-write existing file 's_term.c'"
  1177. else
  1178. sed 's/^X//' << \SHAR_EOF > 's_term.c'
  1179. X/*
  1180. X * Display the terminal setup, query for changes.  A return code of 1
  1181. X * means something was changed, 2 means we have to kill and restart
  1182. X * the input routine.
  1183. X */
  1184. X
  1185. X#include <stdio.h>
  1186. X#include <curses.h>
  1187. X#include "config.h"
  1188. X#include "misc.h"
  1189. X#include "param.h"
  1190. X#include "status.h"
  1191. X
  1192. Xint
  1193. Xterm_setup()
  1194. X{
  1195. X    WINDOW *t_win, *newwin();
  1196. X    int i, num, ret_code;
  1197. X    char *ans, *str_rep(), *str_prompt(), *menu_prompt();
  1198. X    void input_off(), line_set();
  1199. X    static char *v_crio[3] = {"CR", "CR/LF", NULL};
  1200. X    static char *v_duplex[3] = {"FULL", "HALF", NULL};
  1201. X    static char *v_flow[3] = {"NONE", "XON/XOFF", NULL};
  1202. X
  1203. X    t_win = newwin(23, 80, 0, 0);
  1204. X
  1205. X    horizontal(t_win, 0, 0, 32);
  1206. X    mvwattrstr(t_win, 0, 33, A_BOLD, "Terminal Setup");
  1207. X    horizontal(t_win, 0, 48, 32);
  1208. X    mvwprintw(t_win, 4, 22, "1) Hot key (decimal) ...... %d", param->hot);
  1209. X    mvwprintw(t_win, 6, 22, "2) ASCII version of hot ... %s", param->ascii_hot);
  1210. X    mvwprintw(t_win, 9, 22, "3) Duplex ................. %s", param->d_duplex);
  1211. X    mvwprintw(t_win, 11, 22, "4) Flow control ........... %s", param->flow);
  1212. X    mvwprintw(t_win, 13, 22, "5) CR translation (in) .... %s", param->cr_in);
  1213. X    mvwprintw(t_win, 15, 22, "6) CR translation (out) ... %s", param->cr_out);
  1214. X    horizontal(t_win, 19, 0, 80);
  1215. X    mvwattrstr(t_win, 20, 0, A_BOLD, "OPTION ==> ");
  1216. X    mvwaddstr(t_win, 20, 58, "Press <ESC> to return");
  1217. X    wmove(t_win, 20, 12);
  1218. X    touchwin(t_win);
  1219. X    wrefresh(t_win);
  1220. X                    /* get the option number */
  1221. X    ret_code = 0;
  1222. X    while ((i = get_num(t_win, 1)) != -1) {
  1223. X        switch (i) {
  1224. X            case 1:
  1225. X                if ((num = num_prompt(t_win, 4, 50, "Hot key", "decimal code for the hot key")) != -1) {
  1226. X                    param->hot = num;
  1227. X                    ret_code = 1;
  1228. X                }
  1229. X                break;
  1230. X            case 2:
  1231. X                if ((ans = str_prompt(t_win, 6, 50, "ASCII version of hot key", "(printable version)")) != NULL) {
  1232. X                    param->ascii_hot = str_rep(param->ascii_hot, ans);
  1233. X                    ret_code = 1;
  1234. X                }
  1235. X                break;
  1236. X            case 3:
  1237. X                if ((ans = menu_prompt(t_win, 9, 50, "Duplex", v_duplex)) != NULL) {
  1238. X                    param->d_duplex = str_rep(param->d_duplex, ans);
  1239. X                    ret_code = 1;
  1240. X                }
  1241. X                break;
  1242. X            case 4:
  1243. X                if ((ans = menu_prompt(t_win, 11, 50, "Flow control", v_flow)) != NULL) {
  1244. X                    param->flow = str_rep(param->flow, ans);
  1245. X                    line_set();
  1246. X                    ret_code = 1;
  1247. X                }
  1248. X                break;
  1249. X            case 5:
  1250. X                if ((ans = menu_prompt(t_win, 13, 50, "CR translation (in)", v_crio)) != NULL) {
  1251. X
  1252. X                    /*
  1253. X                     * the "add lf to cr" function is
  1254. X                     * performed by the input routine
  1255. X                     */
  1256. X                    param->cr_in = str_rep(param->cr_in, ans);
  1257. X                    status->add_lf = !strcmp(ans, "CR/LF");
  1258. X#ifdef SHAREDMEM
  1259. X                    ret_code = 1;
  1260. X#else /* SHAREDMEM */
  1261. X                    input_off();
  1262. X                    ret_code = 2;
  1263. X#endif /* SHAREDMEM */
  1264. X                }
  1265. X                break;
  1266. X            case 6:
  1267. X                if ((ans = menu_prompt(t_win, 15, 50, "CR translation (out)", v_crio)) != NULL) {
  1268. X                    param->cr_out = str_rep(param->cr_out, ans);
  1269. X                    ret_code = 1;
  1270. X                }
  1271. X                break;
  1272. X            default:
  1273. X                beep();
  1274. X        }
  1275. X        mvwaddch(t_win, 20, 12, (chtype) ' ');
  1276. X        clear_line(t_win, 21, 0, FALSE);
  1277. X        clear_line(t_win, 22, 0, FALSE);
  1278. X        wmove(t_win, 20, 12);
  1279. X        wrefresh(t_win);
  1280. X    }
  1281. X    delwin(t_win);
  1282. X    return(ret_code);
  1283. X}
  1284. SHAR_EOF
  1285. if test 3046 -ne "`wc -c < 's_term.c'`"
  1286. then
  1287.     echo shar: "error transmitting 's_term.c'" '(should have been 3046 characters)'
  1288. fi
  1289. fi
  1290. echo shar: "extracting 's_tty.c'" '(4903 characters)'
  1291. if test -f 's_tty.c'
  1292. then
  1293.     echo shar: "will not over-write existing file 's_tty.c'"
  1294. else
  1295. sed 's/^X//' << \SHAR_EOF > 's_tty.c'
  1296. X/*
  1297. X * Display the TTY setup, query for changes.  A non-zero return code
  1298. X * means something was changed.
  1299. X */
  1300. X
  1301. X#include <stdio.h>
  1302. X#include <curses.h>
  1303. X#include "config.h"
  1304. X#include "misc.h"
  1305. X#include "modem.h"
  1306. X
  1307. Xint
  1308. Xtty_setup()
  1309. X{
  1310. X    WINDOW *tt_win, *newwin();
  1311. X    char message[80], *str, *get_str();
  1312. X    int num, i, j, ret_code;
  1313. X    void disp_tty(), create_modem(), del_modem(), error_win();
  1314. X    void del_tty();
  1315. X
  1316. X    tt_win = newwin(23, 80, 0, 0);
  1317. X
  1318. X    horizontal(tt_win, 0, 0, 34);
  1319. X    mvwattrstr(tt_win, 0, 35, A_BOLD, "TTY Setup");
  1320. X    horizontal(tt_win, 0, 45, 34);
  1321. X    mvwaddstr(tt_win, 2, 22, "TTY name");
  1322. X    mvwaddstr(tt_win, 2, 37, "Modem name");
  1323. X    mvwaddstr(tt_win, 2, 51, "Init speed");
  1324. X                    /* display the current TTY list */
  1325. X    disp_tty(tt_win);
  1326. X                    /* prompt for options */
  1327. X    mvwaddstr(tt_win, 15, 20, "A) Add a TTY entry");
  1328. X    mvwaddstr(tt_win, 16, 20, "D) Delete a TTY entry");
  1329. X    horizontal(tt_win, 19, 0, 80);
  1330. X    mvwattrstr(tt_win, 20, 0, A_BOLD, "OPTION ==> ");
  1331. X    mvwaddstr(tt_win, 20, 58, "Press <ESC> to return");
  1332. X    wmove(tt_win, 20, 12);
  1333. X    touchwin(tt_win);
  1334. X    wrefresh(tt_win);
  1335. X                    /* get the option */
  1336. X    ret_code = 0;
  1337. X    while ((str = get_str(tt_win, 2, "01234356789AaDd", "")) != NULL) {
  1338. X        switch(*str) {
  1339. X            case '0':
  1340. X            case '1':
  1341. X            case '2':
  1342. X            case '3':
  1343. X            case '4':
  1344. X            case '5':
  1345. X            case '6':
  1346. X            case '7':
  1347. X            case '8':
  1348. X            case '9':
  1349. X                i = atoi(str);
  1350. X                    /* if beyond t_entries */
  1351. X                if (i > modem->t_entries) {
  1352. X                    beep();
  1353. X                    break;
  1354. X                }
  1355. X
  1356. X                    /* change the entry  */
  1357. X                if (tty_prompt(tt_win, i-1)) {
  1358. X
  1359. X                    /* requires modem update? */
  1360. X                    create_modem(modem->tname[i-1]);
  1361. X                    del_modem();
  1362. X                    ret_code++;
  1363. X                }
  1364. X                break;
  1365. X            case 'a':
  1366. X            case 'A':    /* add an entry */
  1367. X                if (modem->t_entries == NUM_TTY) {
  1368. X                    sprintf(message, "\"%s\"", modem->m_path);
  1369. X                    error_win(0, "No empty TTY slots in modem/TTY database", message);
  1370. X                    break;
  1371. X                }
  1372. X                    /* prompt for info */
  1373. X                j = modem->t_entries;
  1374. X                if (tty_prompt(tt_win, j)) {
  1375. X
  1376. X                    /* add modem entry? */
  1377. X                    modem->t_entries++;
  1378. X                    create_modem(modem->tname[j]);
  1379. X                    ret_code++;
  1380. X                }
  1381. X                break;
  1382. X            case 'd':
  1383. X            case 'D':    /* delete an entry */
  1384. X                mvwaddstr(tt_win, 21, 0, "Entry number to delete: ");
  1385. X                wrefresh(tt_win);
  1386. X                while ((num = get_num(tt_win, 4)) != -1) {
  1387. X                    /* valid range */
  1388. X                    if (!num || num>modem->t_entries) {
  1389. X                        beep();
  1390. X                        mvwaddstr(tt_win, 21, 24, "   ");
  1391. X                        wmove(tt_win, 21, 24);
  1392. X                        wrefresh(tt_win);
  1393. X                        continue;
  1394. X                    }
  1395. X                    del_tty(num-1);
  1396. X                    del_modem();
  1397. X
  1398. X                    /* show the new list */
  1399. X                    disp_tty(tt_win);
  1400. X                    ret_code++;
  1401. X                    break;
  1402. X                }
  1403. X                break;
  1404. X            default:
  1405. X                beep();
  1406. X                break;
  1407. X        }
  1408. X        mvwaddstr(tt_win, 20, 12, "  ");
  1409. X        clear_line(tt_win, 21, 0, FALSE);
  1410. X        clear_line(tt_win, 22, 0, FALSE);
  1411. X        wmove(tt_win, 20, 12);
  1412. X        wrefresh(tt_win);
  1413. X    }
  1414. X    delwin(tt_win);
  1415. X    return(ret_code);
  1416. X}
  1417. X
  1418. X/*
  1419. X * Display the current TTY list.  No scrolling yet, so if your NUM_TTY is
  1420. X * greater than ten, this routine will need some work.
  1421. X */
  1422. X
  1423. Xstatic void
  1424. Xdisp_tty(win)
  1425. XWINDOW *win;
  1426. X{
  1427. X    int i;
  1428. X
  1429. X    for (i=0; i<NUM_TTY; i++)
  1430. X        mvwprintw(win, i+4, 20, "%2d) %-14.14s %-14.14s  %d\n",
  1431. X         i+1, modem->tty[i], modem->tname[i], modem->init_sp[i]);
  1432. X    return;
  1433. X}
  1434. X
  1435. X/*
  1436. X * Prompt the user for the TTY database info.  A non-zero return code means
  1437. X * something was changed.  The second argument is the zero based index.
  1438. X */
  1439. X
  1440. Xstatic int
  1441. Xtty_prompt(win, i)
  1442. XWINDOW *win;
  1443. Xint i;
  1444. X{
  1445. X    char *ans, t_tty[80], t_tname[80], *str_prompt(), *menu_prompt();
  1446. X    char *str_rep(), *strcpy();
  1447. X    static char *v_baud[8] = {"0", "300", "1200", "2400", "4800", "9600",
  1448. X     "19200", NULL};
  1449. X                    /* get temp TTY */
  1450. X    if ((ans = str_prompt(win, i+4, 24, "TTY name", "")) == NULL)
  1451. X        return(0);
  1452. X
  1453. X    strcpy(t_tty, ans);
  1454. X    clear_line(win, 21, 0, FALSE);
  1455. X
  1456. X                    /* get temp tname */
  1457. X    if ((ans = str_prompt(win, i+4, 39, "Modem name", "")) == NULL)
  1458. X        return(0);
  1459. X
  1460. X    strcpy(t_tname, ans);
  1461. X    clear_line(win, 21, 0, FALSE);
  1462. X
  1463. X                    /* get maximum baud */
  1464. X    if ((ans = menu_prompt(win, i+4, 55, "Init speed", v_baud)) == NULL)
  1465. X        return(0);
  1466. X
  1467. X    wrefresh(win);
  1468. X                    /* store 'em for real */
  1469. X    modem->tty[i] = str_rep(modem->tty[i], t_tty);
  1470. X    modem->tname[i] = str_rep(modem->tname[i], t_tname);
  1471. X    modem->init_sp[i] = atoi(ans);
  1472. X
  1473. X    return(1);
  1474. X}
  1475. X
  1476. X/*
  1477. X * Delete a TTY entry.  Since the list must be contiguous, we collapse the
  1478. X * list to cover the hole we made.
  1479. X */
  1480. X
  1481. Xstatic void
  1482. Xdel_tty(i)
  1483. Xint i;
  1484. X{
  1485. X    extern char *null_ptr;
  1486. X    int j;
  1487. X    char *str_rep();
  1488. X    void free_ptr();
  1489. X                    /* collapse the list */
  1490. X    for (j=i; j<modem->t_entries-1; j++) {
  1491. X        modem->tty[j] = str_rep(modem->tty[j], modem->tty[j+1]);
  1492. X        modem->tname[j] = str_rep(modem->tname[j], modem->tname[j+1]);
  1493. X        modem->init_sp[j] = modem->init_sp[j+1];
  1494. X    }
  1495. X    j = modem->t_entries-1;
  1496. X                    /* zap the entry */
  1497. X    free_ptr(modem->tty[j]);
  1498. X    free_ptr(modem->tname[j]);
  1499. X    modem->tty[j] = null_ptr;
  1500. X    modem->tname[j] = null_ptr;
  1501. X    modem->init_sp[j] = 0;
  1502. X                    /* update the count */
  1503. X    modem->t_entries--;
  1504. X    if (modem->t_cur >= modem->t_entries)
  1505. X        modem->t_cur = -1;
  1506. X    return;
  1507. X}
  1508. SHAR_EOF
  1509. if test 4903 -ne "`wc -c < 's_tty.c'`"
  1510. then
  1511.     echo shar: "error transmitting 's_tty.c'" '(should have been 4903 characters)'
  1512. fi
  1513. fi
  1514. echo shar: "extracting 'screen.c'" '(2024 characters)'
  1515. if test -f 'screen.c'
  1516. then
  1517.     echo shar: "will not over-write existing file 'screen.c'"
  1518. else
  1519. sed 's/^X//' << \SHAR_EOF > 'screen.c'
  1520. X/*
  1521. X * Routines to read and copy the virtual screen image file.
  1522. X */
  1523. X
  1524. X#include <stdio.h>
  1525. X#include <curses.h>
  1526. X#include "config.h"
  1527. X#include "param.h"
  1528. X#include "status.h"
  1529. X
  1530. X/*
  1531. X * Do a screen dump.  Actually, the screen is already dumped, all we
  1532. X * do is copy the file.
  1533. X */
  1534. X
  1535. Xvoid
  1536. Xscreen_dump()
  1537. X{
  1538. X    FILE *fp_in, *fp_out, *my_fopen();
  1539. X    char buf[MAX_COL];
  1540. X    void error_win();
  1541. X    int i;
  1542. X                    /* open for append */
  1543. X    if (!(fp_out = my_fopen(param->dumpfile, "a"))) {
  1544. X        sprintf(buf, "\"%s\" for write", param->dumpfile);
  1545. X        error_win(0, "Can't open screen dump file", buf);
  1546. X        return;
  1547. X    }
  1548. X#ifdef SHAREDMEM
  1549. X    for (i=0; i<LINES; i++)
  1550. X        fprintf(fp_out, "%s\n", status->vs[i]);
  1551. X
  1552. X#else /* SHAREDMEM */
  1553. X                    /* not guaranteed to exist yet */
  1554. X    if (!(fp_in = my_fopen(status->vs_path, "r"))) {
  1555. X        fclose(fp_in);
  1556. X        return;
  1557. X    }
  1558. X                    /* skip the x, y coordinates */
  1559. X    fgets(buf, 10, fp_in);
  1560. X
  1561. X    while (fgets(buf, MAX_COL, fp_in) != NULL)
  1562. X        fputs(buf, fp_out);
  1563. X
  1564. X    fclose(fp_in);
  1565. X#endif /* SHAREDMEM */
  1566. X
  1567. X    fclose(fp_out);
  1568. X
  1569. X    return;
  1570. X}
  1571. X
  1572. X/*
  1573. X * Read the virtual screen and paint its contents to the stdscr using
  1574. X * curses(3).  Move the cursor where it belongs.
  1575. X */
  1576. X
  1577. Xvoid
  1578. Xload_vs()
  1579. X{
  1580. X    register int i;
  1581. X    FILE *fp, *my_fopen();
  1582. X    int row, col, max_col;
  1583. X    char buf[MAX_COL];
  1584. X
  1585. X    clearok(curscr, TRUE);
  1586. X    erase();
  1587. X
  1588. X#ifdef SHAREDMEM
  1589. X    for (i=0; i<LINES; i++)
  1590. X        mvaddstr(i, 0, status->vs[i]);
  1591. X
  1592. X    move(status->row, status->col);
  1593. X#else /* SHAREDMEM */
  1594. X                    /* not guaranteed to exist yet */
  1595. X    if (!(fp = my_fopen(status->vs_path, "r")))
  1596. X        return;
  1597. X                    /* get the x, y coordinates */
  1598. X    fgets(buf, 10, fp);
  1599. X    sscanf(buf, "%d,%d\n", &row, &col);
  1600. X
  1601. X    i = 0;
  1602. X    max_col = (COLS > MAX_COL-1) ? MAX_COL-1 : COLS;
  1603. X    while (fgets(buf, MAX_COL, fp) != NULL) {
  1604. X                    /* zap the line feed */
  1605. X        buf[max_col] = '\0';
  1606. X        mvaddstr(i++, 0, buf);
  1607. X    }
  1608. X    fclose(fp);
  1609. X    move(row, col);
  1610. X#endif /* SHAREDMEM */
  1611. X
  1612. X    refresh();
  1613. X    return;
  1614. X}
  1615. X
  1616. X/*
  1617. X * Zap the virtual screen file (or clear it).
  1618. X */
  1619. X
  1620. Xvoid
  1621. Xzap_vs()
  1622. X{
  1623. X#ifdef SHAREDMEM
  1624. X    status->clr = 1;
  1625. X#else /* SHAREDMEM */
  1626. X    unlink(status->vs_path);
  1627. X#endif /* SHAREDMEM */
  1628. X    return;
  1629. X}
  1630. SHAR_EOF
  1631. if test 2024 -ne "`wc -c < 'screen.c'`"
  1632. then
  1633.     echo shar: "error transmitting 'screen.c'" '(should have been 2024 characters)'
  1634. fi
  1635. fi
  1636. echo shar: "extracting 'script.c'" '(3790 characters)'
  1637. if test -f 'script.c'
  1638. then
  1639.     echo shar: "will not over-write existing file 'script.c'"
  1640. else
  1641. sed 's/^X//' << \SHAR_EOF > 'script.c'
  1642. X/*
  1643. X * Spawn a shell with file descriptors that look like this:
  1644. X *
  1645. X *              +---------+
  1646. X *   TTYin ---> | input   | ---> screen (& virtual screen)
  1647. X *              | program |
  1648. X *              +---------+
  1649. X *                   |                     +---------+
  1650. X *                  pipe ----------> stdin |         |
  1651. X *                                         |  shell  |
  1652. X *   TTYout <---------------------- stdout |         |
  1653. X *                                         +---------+
  1654. X *
  1655. X * The input program has a routine that duplicates the TTYin and sends it
  1656. X * down a pipe.  The other end of the pipe is the stdin to the shell script.
  1657. X * This allows the characters to appear on the screen *and* be interpreted
  1658. X * by the shell script.
  1659. X */
  1660. X
  1661. X#include <stdio.h>
  1662. X#include <signal.h>
  1663. X#include <curses.h>
  1664. X#include <errno.h>
  1665. X#include "config.h"
  1666. X#include "dial_dir.h"
  1667. X#include "status.h"
  1668. X
  1669. X#ifdef BSD
  1670. X#include <sys/file.h>
  1671. X#else /* BSD */
  1672. X#include <fcntl.h>
  1673. X#endif /* BSD */
  1674. X
  1675. Xvoid
  1676. Xdo_script(extra)
  1677. Xchar *extra;
  1678. X{
  1679. X    extern int fd, errno;
  1680. X    SIG_TYPE (*istat)(), (*qstat)();
  1681. X    int epid, dup_pipe[2], want_out, sig_status;
  1682. X    char buf[80], *ttyname(), *strcpy(), *path, *findfile();
  1683. X    void _exit(), error_win(), input_off(), do_input();
  1684. X    unsigned int sleep();
  1685. X
  1686. X                    /* if empty */
  1687. X    if (*dir->script[dir->d_cur] == '\0')
  1688. X        return;
  1689. X                    /* if a device */
  1690. X    if (chk_script(dir->script[dir->d_cur]))
  1691. X        return;
  1692. X                    /* find the script file */
  1693. X    if ((path = findfile(extra, dir->script[dir->d_cur])) == NULL) {
  1694. X        sprintf(buf, "Can't locate script \"%s\"", dir->script[dir->d_cur]);
  1695. X        error_win(0, buf, "");
  1696. X        return;
  1697. X    }
  1698. X                    /* execute permission ? */
  1699. X    if (access(path, 1)) {
  1700. X        sprintf(buf, "\"%s\"", path);
  1701. X        error_win(0, "No execute permission on script file", buf);
  1702. X        return;
  1703. X    }
  1704. X                    /* create a fd for duplicating input */
  1705. X    if (pipe(dup_pipe) < 0)
  1706. X        return;
  1707. X
  1708. X    status->dup_fd = dup_pipe[1];
  1709. X                    /* start input duplication */
  1710. X    do_input();
  1711. X
  1712. X    if (!(epid = fork())) {
  1713. X                    /* create a new process group ID */
  1714. X#ifdef BSD
  1715. X        setpgrp(0, getpid());
  1716. X#else /* BSD */
  1717. X        setpgrp();
  1718. X#endif /* BSD */
  1719. X                    /* recreate the device name */
  1720. X        strcpy(buf, ttyname(fd));
  1721. X        close(fd);
  1722. X                    /* swap the stdin */
  1723. X        close(0);
  1724. X        dup(dup_pipe[0]);
  1725. X                    /* swap the stdout */
  1726. X        close(1);
  1727. X#ifdef UNIXPC
  1728. X/*
  1729. X * Some strange things here... The OBM uses the second parameter of 
  1730. X * open() to determine if the the port should be in the DATA mode or
  1731. X * the VOICE mode.  Therefore, we must always open with read and write.
  1732. X */
  1733. X        if (!strncmp(buf, "/dev/ph", 7))
  1734. X            open(buf, O_RDWR);
  1735. X        else
  1736. X#endif /* UNIXPC */
  1737. X
  1738. X        open(buf, O_WRONLY);
  1739. X#ifdef SETUGID
  1740. X        setgid(getgid());
  1741. X        setuid(getuid());
  1742. X#endif /* SETUGID */
  1743. X
  1744. X        execl("/bin/sh", "sh", "-c", path, (char *) 0);
  1745. X        _exit(1);
  1746. X    }
  1747. X    istat = signal(SIGINT, SIG_IGN);
  1748. X    qstat = signal(SIGQUIT, SIG_IGN);
  1749. X
  1750. X    /*
  1751. X     * Check the keyboard while the script is being "played".  If the
  1752. X     * user hits the <ESC> key, then kill the entire process group
  1753. X     * associated with the new shell.
  1754. X     */
  1755. X    want_out = 0;
  1756. X    while(1) {
  1757. X        switch(wait_key(stdscr, 1)) {
  1758. X            case -1:    /* timed out */
  1759. X                break;
  1760. X            case 27:    /* a user abort */
  1761. X#ifdef BSD
  1762. X                killpg(epid, SIGKILL);
  1763. X#else /* BSD */
  1764. X                kill(-epid, SIGKILL);
  1765. X#endif /* BSD */
  1766. X                want_out++;
  1767. X                break;
  1768. X            default:
  1769. X                beep();
  1770. X                break;
  1771. X        }
  1772. X        if (want_out)
  1773. X            break;
  1774. X                    /* see if the process it still active */
  1775. X#ifdef BSD
  1776. X        if ((kill(epid, 0) == -1) && errno == ESRCH) 
  1777. X#else /* BSD */
  1778. X        if ((kill(-epid, 0) == -1) && errno == ESRCH) 
  1779. X#endif /* BSD */
  1780. X            break;
  1781. X    }
  1782. X                    /* wait for the zombie process */
  1783. X    wait(&sig_status);
  1784. X
  1785. X    signal(SIGINT, istat);
  1786. X    signal(SIGQUIT, qstat);
  1787. X                    /* shut down the duplication of input */
  1788. X    status->dup_fd = -1;
  1789. X
  1790. X#ifndef SHAREDMEM
  1791. X    input_off();
  1792. X#endif /* SHAREDMEM */
  1793. X
  1794. X    close(dup_pipe[0]);
  1795. X    close(dup_pipe[1]);
  1796. X    sleep(1);
  1797. X    beep();
  1798. X    return;
  1799. X}
  1800. SHAR_EOF
  1801. if test 3790 -ne "`wc -c < 'script.c'`"
  1802. then
  1803.     echo shar: "error transmitting 'script.c'" '(should have been 3790 characters)'
  1804. fi
  1805. fi
  1806. echo shar: "extracting 'st_line.c'" '(2103 characters)'
  1807. if test -f 'st_line.c'
  1808. then
  1809.     echo shar: "will not over-write existing file 'st_line.c'"
  1810. else
  1811. sed 's/^X//' << \SHAR_EOF > 'st_line.c'
  1812. X/*
  1813. X * Display the status line.  Up to now, we've never really cared how
  1814. X * large the physical screen was... but now we want the status line
  1815. X * on the bottom.
  1816. X */
  1817. X
  1818. X#include <curses.h>
  1819. X#include "config.h"
  1820. X#include "dial_dir.h"
  1821. X#include "misc.h"
  1822. X#include "modem.h"
  1823. X#include "param.h"
  1824. X#include "status.h"
  1825. X
  1826. Xvoid
  1827. Xst_line(message)
  1828. Xchar *message;
  1829. X{
  1830. X    extern int xmc;
  1831. X    WINDOW *sl_win, *newwin();
  1832. X    int d, x, y;
  1833. X    static char *dn[2] = {"FDX", "HDX"};
  1834. X    static char *ln[2] = {"LOG OFF", "LOG ON"};
  1835. X    static char *pn[2] = {"PTR OFF", "PTR ON "};
  1836. X    char buf[80], field_one[15], *cur_tty;
  1837. X
  1838. X                    /* is anybody missing? */
  1839. X    if (dir == NULL || modem == NULL || param == NULL)
  1840. X        return;
  1841. X                    /* remember where we parked the car.. */
  1842. X    getyx(stdscr, y, x);
  1843. X
  1844. X    sl_win = newwin(1, 80, LINES-1, 0);
  1845. X                    /* duplex message */
  1846. X    d = 0;
  1847. X    if (dir->duplex[dir->d_cur] == 'H')
  1848. X        d++;
  1849. X                    /* the current TTY */
  1850. X    cur_tty = "No TTY";
  1851. X    if (modem->t_cur != -1)
  1852. X        cur_tty = modem->tty[modem->t_cur];
  1853. X
  1854. X    /*
  1855. X     * The philosophy is:  If you press a command sequence that
  1856. X     * doesn't generate a window on the screen, then show the user
  1857. X     * what's going on in the status line.
  1858. X     */
  1859. X    if (*message == '\0')
  1860. X        sprintf(field_one, " %4.4s-0 HELP  ", param->ascii_hot);
  1861. X    else
  1862. X        sprintf(field_one, " %-13.13s", message);
  1863. X
  1864. X#ifdef XMC_BROKE
  1865. X    if (xmc > 0)
  1866. X        sprintf(buf, "%s | %-9.9s| %s | %5d %c%d%d | %-7.7s | %-7.7s | %-5.5s|%-5.5s",
  1867. X         field_one, cur_tty, dn[d], dir->baud[dir->d_cur],
  1868. X         dir->parity[dir->d_cur], dir->dbits[dir->d_cur],
  1869. X         dir->sbits[dir->d_cur], ln[status->log], pn[status->print],
  1870. X         param->cr_in, param->cr_out);
  1871. X    else
  1872. X#endif /* XMC_BROKE */
  1873. X        sprintf(buf, "%s | %-9.9s| %s | %5d %c%d%d | %-7.7s | %-7.7s | %-5.5s| %-5.5s",
  1874. X         field_one, cur_tty, dn[d], dir->baud[dir->d_cur],
  1875. X         dir->parity[dir->d_cur], dir->dbits[dir->d_cur],
  1876. X         dir->sbits[dir->d_cur], ln[status->log], pn[status->print],
  1877. X         param->cr_in, param->cr_out);
  1878. X
  1879. X    if (xmc > 0) {
  1880. X        touchwin(sl_win);
  1881. X        werase(sl_win);
  1882. X        wrefresh(sl_win);
  1883. X    }
  1884. X    wattrstr(sl_win, A_STANDOUT, buf);
  1885. X    wrefresh(sl_win);
  1886. X                    /* go ahead and delete it now */
  1887. X    delwin(sl_win);
  1888. X    move(y, x);
  1889. X    return;
  1890. X}
  1891. SHAR_EOF
  1892. if test 2103 -ne "`wc -c < 'st_line.c'`"
  1893. then
  1894.     echo shar: "error transmitting 'st_line.c'" '(should have been 2103 characters)'
  1895. fi
  1896. fi
  1897. echo shar: "extracting 'status.h'" '(808 characters)'
  1898. if test -f 'status.h'
  1899. then
  1900.     echo shar: "will not over-write existing file 'status.h'"
  1901. else
  1902. sed 's/^X//' << \SHAR_EOF > 'status.h'
  1903. X/*
  1904. X * The status flags, and other various changeable things.  Obviously
  1905. X * the "config.h" file must appear before this file.
  1906. X */
  1907. X
  1908. X#define MAX_ROW        64
  1909. X#define MAX_COL        133
  1910. X#define PATH        128
  1911. X
  1912. Xstruct STATUS {
  1913. X    int    fd;            /* file descriptor for TTY */
  1914. X    int    dup_fd;            /* for duplicating input */
  1915. X    int    add_lf;            /* add <CR> to <LF>? */
  1916. X    int    log;            /* status of log option */
  1917. X    int    print;            /* status of print option */
  1918. X    char    log_path[PATH];        /* data logging file */
  1919. X#ifdef SHAREDMEM
  1920. X    int    clr;            /* flag to clear the screen */
  1921. X    int    row;            /* cursor row position */
  1922. X    int    col;            /* cursor column position */
  1923. X    char    vs[MAX_ROW][MAX_COL];    /* the virtual screen */
  1924. X#else /* SHAREDMEM */
  1925. X    char    vs_path[PATH];        /* virtual screen file */
  1926. X#endif /* SHAREDMEM */
  1927. X};
  1928. X
  1929. X#ifndef MAIN
  1930. Xextern struct STATUS *status;
  1931. X#endif /* MAIN */
  1932. SHAR_EOF
  1933. if test 808 -ne "`wc -c < 'status.h'`"
  1934. then
  1935.     echo shar: "error transmitting 'status.h'" '(should have been 808 characters)'
  1936. fi
  1937. fi
  1938. echo shar: "extracting 'strings.c'" '(4200 characters)'
  1939. if test -f 'strings.c'
  1940. then
  1941.     echo shar: "will not over-write existing file 'strings.c'"
  1942. else
  1943. sed 's/^X//' << \SHAR_EOF > 'strings.c'
  1944. X/*
  1945. X * Miscellaneous string routines.
  1946. X */
  1947. X
  1948. X#define STRSTR
  1949. X
  1950. X#include <stdio.h>
  1951. X#include "config.h"
  1952. X
  1953. X/*
  1954. X * Do a fancy string copy.  If NULL, return null.  If pointer to NULL, then
  1955. X * return the special "null_ptr" variable.  If a normal copy, allocate
  1956. X * memory first.
  1957. X */
  1958. X
  1959. Xchar *
  1960. Xstr_dup(str)
  1961. Xchar *str;
  1962. X{
  1963. X    extern char *null_ptr;
  1964. X    char *ret, *malloc(), *strcpy();
  1965. X    void error_win();
  1966. X
  1967. X    if (str == NULL)
  1968. X        return(NULL);
  1969. X                    /* if pointer to null */
  1970. X    if (*str == '\0')
  1971. X        return(null_ptr);
  1972. X
  1973. X    if (!(ret = malloc((unsigned int) strlen(str)+1)))
  1974. X        error_win(1, "Out of memory", "");
  1975. X
  1976. X    strcpy(ret, str);
  1977. X    return(ret);
  1978. X}
  1979. X
  1980. X/*
  1981. X * Perform the free(2) function, but check for NULL and the special
  1982. X * "null_ptr" variable first.
  1983. X */
  1984. X
  1985. Xvoid
  1986. Xfree_ptr(str)
  1987. Xchar *str;
  1988. X{
  1989. X    extern char *null_ptr;
  1990. X    void free();
  1991. X
  1992. X    if (str != NULL && str != null_ptr)
  1993. X        free(str);
  1994. X    return;
  1995. X}
  1996. X
  1997. X/*
  1998. X * Replace a string.  Follows the same convention as str_dup(), except
  1999. X * that realloc() is used instead of malloc().  Returns a pointer to
  2000. X * the new string (which may have moved).
  2001. X */
  2002. X
  2003. Xchar *
  2004. Xstr_rep(s1, s2)
  2005. Xchar *s1, *s2;
  2006. X{
  2007. X    extern char *null_ptr;
  2008. X    void free_ptr(), error_win();
  2009. X    char *s, *malloc(), *realloc(), *strcpy();
  2010. X
  2011. X                    /* copy null pointer ? */
  2012. X    if (s2 == NULL) {
  2013. X        free_ptr(s1);
  2014. X        return(NULL);
  2015. X    }
  2016. X    if (s2 == '\0') {
  2017. X        free_ptr(s1);
  2018. X        return(null_ptr);
  2019. X    }
  2020. X                    /* use realloc()? */
  2021. X    if (s1 == NULL || s1 == null_ptr) {
  2022. X        if (!(s = malloc((unsigned int) strlen(s2)+1)))
  2023. X            error_win(1, "Out of memory", "");
  2024. X    }
  2025. X    else {
  2026. X        if (!(s = realloc(s1, (unsigned int) strlen(s2)+1)))
  2027. X            error_win(1, "Out of memory", "");
  2028. X    }
  2029. X
  2030. X    strcpy(s, s2);
  2031. X    return(s);
  2032. X}
  2033. X
  2034. X/*
  2035. X * This routine is similar to strtok(3).  But this version handles missing
  2036. X * tokens by returning a pointer to null.  Also it takes a single separator
  2037. X * character as an argument.  Returns a NULL on end of string or error.
  2038. X */
  2039. X
  2040. Xchar *
  2041. Xstr_tok(str, c)
  2042. Xchar *str, c;
  2043. X{
  2044. X    char *strchr();
  2045. X    static char *ptr, *sep;
  2046. X                    /* start at beginning */
  2047. X    if (str != NULL)
  2048. X        ptr = str;
  2049. X    else
  2050. X        ptr = sep;
  2051. X                    /* at the end? */
  2052. X    if (*ptr == '\0')
  2053. X        return(NULL);
  2054. X                    /* no separator? */
  2055. X    if (!(sep = strchr(ptr, c)))
  2056. X        return(NULL);
  2057. X                    /* zap the sep, move past it */
  2058. X    *sep = '\0';
  2059. X    sep++;
  2060. X
  2061. X    return(ptr);
  2062. X}
  2063. X
  2064. X#ifdef STRSTR
  2065. X/*
  2066. X * Return a pointer to the first occurance of string str2 in str1.
  2067. X * Returns a NULL if str2 is not in str1.
  2068. X */
  2069. X
  2070. Xchar *
  2071. Xstrstr(str1, str2)
  2072. Xchar *str1, *str2;
  2073. X{
  2074. X    int len;
  2075. X
  2076. X    len = strlen(str2);
  2077. X    while (*str1) {
  2078. X        if (*str2 == *str1) {
  2079. X            if (!strncmp(str2, str1, len))
  2080. X                return(str1);
  2081. X        }
  2082. X        str1++;
  2083. X    }
  2084. X    return(NULL);
  2085. X}
  2086. X#endif /* STRSTR */
  2087. X
  2088. X#ifdef BSD
  2089. X/*
  2090. X * Returns the length of the initial segment of string which consists
  2091. X * entirely of characters from charset.
  2092. X */
  2093. X
  2094. Xint
  2095. Xstrspn(string, charset)
  2096. Xchar    *string;
  2097. Xregister char    *charset;
  2098. X{
  2099. X    register char *p, *q;
  2100. X
  2101. X    for(q=string; *q != '\0'; ++q) {
  2102. X        for(p=charset; *p != '\0' && *p != *q; ++p)
  2103. X            ;
  2104. X        if(*p == '\0')
  2105. X            break;
  2106. X    }
  2107. X    return(q-string);
  2108. X}
  2109. X
  2110. X/*
  2111. X * Strtok considers string to consist of a sequence of zero or more
  2112. X * text tokens separated by spans of one or more characters from sepset.
  2113. X */
  2114. X
  2115. Xchar *
  2116. Xstrtok(string, sepset)
  2117. Xchar    *string, *sepset;
  2118. X{
  2119. X    register char    *p, *q, *r;
  2120. X    static char    *savept;
  2121. X    char *strpbrk();
  2122. X
  2123. X    /*first or subsequent call*/
  2124. X    p = (string == NULL)? savept: string;
  2125. X
  2126. X    if(p == 0)        /* return if no tokens remaining */
  2127. X        return(NULL);
  2128. X
  2129. X    q = p + strspn(p, sepset);    /* skip leading separators */
  2130. X
  2131. X    if(*q == '\0')        /* return if no tokens remaining */
  2132. X        return(NULL);
  2133. X
  2134. X    if((r = strpbrk(q, sepset)) == NULL)    /* move past token */
  2135. X        savept = 0;    /* indicate this is last token */
  2136. X    else {
  2137. X        *r = '\0';
  2138. X        savept = ++r;
  2139. X    }
  2140. X    return(q);
  2141. X}
  2142. X
  2143. X/*
  2144. X * Return ptr to first occurrence of any character from `brkset'
  2145. X * in the character string `string'; NULL if none exists.
  2146. X */
  2147. X
  2148. Xchar *
  2149. Xstrpbrk(string, brkset)
  2150. Xregister char *string, *brkset;
  2151. X{
  2152. X    register char *p;
  2153. X
  2154. X    if(!string || !brkset)
  2155. X        return(0);
  2156. X    do {
  2157. X        for(p=brkset; *p != '\0' && *p != *string; ++p)
  2158. X            ;
  2159. X        if(*p != '\0')
  2160. X            return(string);
  2161. X    }
  2162. X    while(*string++);
  2163. X    return(0);
  2164. X}
  2165. X
  2166. X/*
  2167. X * Copies the character c, n times to string s
  2168. X */
  2169. X
  2170. Xchar *
  2171. Xmemset(s, c, n)
  2172. Xchar *s, c;
  2173. Xint n;
  2174. X{
  2175. X    char *s1 = s;
  2176. X
  2177. X    while (n > 0) {
  2178. X        --n;
  2179. X        *s++ = c;
  2180. X    }
  2181. X    return(s1);
  2182. X}
  2183. X#endif /* BSD */
  2184. SHAR_EOF
  2185. if test 4200 -ne "`wc -c < 'strings.c'`"
  2186. then
  2187.     echo shar: "error transmitting 'strings.c'" '(should have been 4200 characters)'
  2188. fi
  2189. fi
  2190. exit 0
  2191. #    End of shell archive
  2192.  
  2193.  
  2194.